import time
from selenium.webdriver.common.by import By
from common.Utils import QE_Driver

#测试问卷考试系统首页

class QE_HomeTest:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://8.155.1.153:8081/home"
        self.driver = QE_Driver.driver
        self.driver.get(self.url)

    #进行首页元素的查找检查
    def HomeCheckElement(self):
        #检查首页标题元素
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > div")
        #检查问卷数元素
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(1) > div > div.ant-statistic-title")
        #检查考试数元素
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(2) > div > div.ant-statistic-title")
        #检查我的考试按钮
        self.driver.find_element(By.CSS_SELECTOR, "#rc-tabs-0-tab-exam")
        #检查我的问卷按钮
        self.driver.find_element(By.CSS_SELECTOR, "#rc-tabs-0-tab-survey")
        #检查问卷记录按钮
        self.driver.find_element(By.CSS_SELECTOR, "#rc-tabs-0-tab-surveyHistory")
        #检查考试记录按钮
        self.driver.find_element(By.CSS_SELECTOR, "#rc-tabs-0-tab-examHistory")
        #检查创建问卷按钮
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(1)")
        #检查创建考试按钮
        self.driver.find_element(By.CSS_SELECTOR, "#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(2)")

        #添加屏幕截图
        QE_Driver.getScreenshot()


# home = QE_HomeTest()
# home.HomeCheckElement()

#指定浏览器的退出
# QE_Driver.driver.quit()
